package topcoder;

import java.util.*;

public class SurveillanceSystem {

	class Run {
		
		HashMap<Integer, Set<Integer>> A = new HashMap<Integer, Set<Integer>>();
		HashSet<Integer> U = new HashSet<Integer>();
		HashSet<Integer> I = null;
		HashSet<Integer> P = new HashSet<Integer>();
		int[] R;
		int L;
		int N;
		
		public Run(String S, int[] R, int L) {
			this.R = R;
			this.L = L;
			N = S.length();
			calcA(S);
			
			for (int i = 0; i <= N-L; i++) {
				P.add(i);
			}
			
			calcUI(0, new HashSet<Integer>());
		}
		
		
		String ret() {
			char[] rs = new char[N];
			
			for(int i = 0; i < N; i++)
				rs[i] = '-';
	
			for(int p : U)
				rs[p] = '?';
				
			for(int p: I)
				rs[p] = '+';
			
			return String.valueOf(rs);
		}
		
		
		void calcUI(int i, HashSet<Integer> W) {
			if (i == R.length) {
				U.addAll(W);
				if (I == null)
					I = new HashSet<Integer>(W);
				else
					I.retainAll(W);
				return;
			}
			
			HashSet<Integer> V = new HashSet<Integer>(P);
			V.retainAll(A.get(R[i]));
			
			for(int v : V) {
				HashSet<Integer> W2 = new HashSet<Integer>(W);
				for(int j = 0; j < L; j++) {
					W2.add(v + j);
				}
				P.remove(v);
				calcUI(i+1, W2);
				P.add(v);
			}
		}
		
		void calcA(String S) {
			int[] C = new int[N];
			for (int i = 0; i < N; i++) {
				if (S.charAt(i) == 'X')
					C[i] = 1;
				else
					C[i] = 0;
			}
			
			int sum = 0;
			for (int i = 0; i < L; i++) {
				sum += C[i];
			}
			
			if (!A.containsKey(sum))
				A.put(sum, new HashSet<Integer>());
			
			A.get(sum).add(0);
			
			for (int i = 1; i <= N-L; i++) {
				sum -= C[i-1];
				sum += C[i+L-1];
				if (!A.containsKey(sum))
					A.put(sum, new HashSet<Integer>());
				
				A.get(sum).add(i);
			}
			
		}
		
	}
	
	
	public String getContainerInfo(String containers, int[] reports, int L) {
		Run r = new Run(containers, reports, L);
		return r.ret();
	}
	
	
	public static void main(String[] args) {
		
		SurveillanceSystem ss = new SurveillanceSystem();
		
		int[] R = {1,2};
		System.out.println(ss.getContainerInfo("-X--XX", R, 3));
	}
}
